//
// Created by 45512 on 2021/11/24.
//16:08
/*
1.这里注意一个是数据越界问题，通过typedef设置long long
2.第二个是使用CPP14比CPP11更好用，在CPP14中100分，CPP11中60分
*/
#include <iostream>
using namespace std;
typedef long long ll;
const ll N = 1e10;
struct A{
    ll first;
    ll second;
};
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    A a1[a+1]={0};
    A a2[b+1]={0};
    for (ll i=1;i<=a;i++){
        cin >> a1[i].first >> a1[i].second;
    }
    for (ll i=1;i<=b;i++){
        cin >> a2[i].first >> a2[i].second;
    }
    ll sum =0;
    ll temp=0;
    for (ll i=1;i<=a;i++){
        ll j = temp+1;
        for (;j<=b;j++){
            if (a1[i].first==a2[j].first){
                sum += a1[i].second * a2[j].second;
                temp=j;
                break;
            }
            if (a2[j].first>a1[i].first){
                break;
            }
        }
    }
    cout << sum << endl;
    return 0;
}
